package com.digitalchina.lxnsy.activity.management.message;

import android.os.Bundle;
import androidx.viewpager.widget.ViewPager;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.adapter.TabViewPagerAdapter;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.entity.PagerItemVO;
import com.digitalchina.lxnsy.toolkit.GotoUtil;
import com.digitalchina.lxnsy.view.MyTabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.activity.management
 * 创建人：郑皓
 * 创建时间：2019/4/26 14:16
 * 修改备注：
 * ================================================
 */
public class MessageListActivity extends BaseActivity {

    @Bind(R.id.tab)
    MyTabLayout tab;
    @Bind(R.id.viewpager)
    ViewPager viewpager;

    /*每个 tab 的 item*/
    private List<PagerItemVO> mList = new ArrayList<>();
    private String[] title = {"全部", "已查看", "待查看"};

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_msg_list);
        setTitle("消息列表");
        setRightText("搜索");
    }

    @Override
    public void initMember() {

        for (int i = 0; i < title.length; i++) {
            MsgListFragment fragment = new MsgListFragment();
            Bundle bundle = new Bundle();
            bundle.putString("type", String.valueOf(i));
            fragment.setArguments(bundle);
            mList.add(new PagerItemVO(title[i], fragment));
        }

        viewpager.setAdapter(new TabViewPagerAdapter(getFragmentManager(), mList));
        viewpager.setOffscreenPageLimit(title.length);
        tab.setViewPager(viewpager);
    }

    @Override
    public void addListener() {

    }

    @Override
    public void setHandler() {

    }

    @Override
    public void callBack(Object object) {

    }

    @Override
    public void rightOnClick() {
        GotoUtil.gotoActivity(activity, SearchMsgListActivity.class);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
